package com.demo.proxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

/**
 * Created by chenhe17596 on 2017/6/24.
 */
public class RPCProxyClient implements InvocationHandler {

    private Object object;

    public  RPCProxyClient(Object object){
        this.object=object;
    }

    public static Object getProxy(Object object){
        System.out.println(object);


        Object obj = Proxy.newProxyInstance(object.getClass().getClassLoader(),object.getClass().getInterfaces(),new RPCProxyClient(object));
        return obj;
    }

    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        Object result = new Object();
        System.out.println("object class: "+proxy.getClass());
        System.out.println("method: "+ method.getName());
        System.out.println(args);
        return proxy;
    }
}
